#ifndef _HTTP_MSG_PARSE_H_
#define _HTTP_MSG_PARSE_H_

#include <map>
#include <iostream>

#include "tinyxml.h"
#include "tinystr.h"
#include "Logger.h"

using namespace std;

#define XML_VERSION "1.0"
#define XML_ENCODING "UTF-8"

class HttpParser {
    public:
        HttpParser();
	~HttpParser();
        void clear();
	string getParam() { return m_param; }
	long getRangeStart() { return m_range_start; }
	long getRangeEnd() { return m_range_end; }
        long getIngressCapacity() { return m_ingress_capacity; }
       
        void parseLocatingRequestMsg(string &http_msg);
        string getXmlValueByKey(const string &key);
        void parseTransferRequestMsg(string &http_msg);
        void parseXml(string xml_text);

private:
	string m_param;
        long m_range_start;
        long m_range_end;
        long m_ingress_capacity;
        static string s_separator;
	map<string,string> m_xmlKV;
        string extract_between(string &text, string &start_word, string &end_word, string::size_type pos = 0);
	void parseElement(TiXmlElement* xmlEle);
};

#endif

